#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
int main()
{
    printf("please input char device name /dev/<char device>\n");
    char char_device[20] = {0};
    int read_count = read(0, char_device, 19);
    if (read_count < 0)
    {
        perror(strerror(errno));
        exit(errno);
    };
    char * newline = strchr(char_device,'\n');
    if (newline){
        *newline = 0;
    }else{
        printf("input is to long\n");
        exit(1);
    }
    printf("your char_device is %s\n",char_device);
    int fd = open(char_device, O_RDONLY);
    char buf[11] = {0};
    int count = read(fd, buf, 10);
    printf("read count %d\n", count);
    printf("%s\n", buf);
}